
package com.hjf.ditubiaozhu.base;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;

import com.trello.rxlifecycle.components.support.RxAppCompatActivity;



public abstract class BaseActivity extends RxAppCompatActivity {
    //public LoadingDialog loadingDialog;
    public Context mContext;

    public <T extends View> T findById(int id) {
        return (T) findViewById(id);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
        setContentView(getLayoutId());
        //初始化数据
        initData();
        //初始化控件
        init(savedInstanceState);
        //初始化toolbar
        initToolBar();

    }

    @Override
    protected void onStop() {
        // TODO: Implement this method
        super.onStop();

    }

    @Override
    protected void onStart() {
        // TODO: Implement this method
        super.onStart();
    }


    protected abstract int getLayoutId();

    protected abstract void initData();

    protected abstract void init(Bundle savedInstanceState);

    protected abstract void initToolBar();



//    //显示加载中对话框
//    public void showLoadingDialog(String title) {
//        loadingDialog = new LoadingDialog(this, title);
//        //显示Dialog
//        loadingDialog.show();
//
//    }
//
//    //隐藏加载中对话框
//    public void hideLoadingDialog() {
//        //关闭Dialog
//        if (loadingDialog !=null){
//            loadingDialog.close();
//
//        }
//    }
    public void toast(String toast){
        Toast.makeText(this,toast, Toast.LENGTH_SHORT).show();
    }
}
